package com.tensquare.user.controller;

import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import com.tensquare.user.pojo.User;
import com.tensquare.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@ResponseBody
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(method = RequestMethod.GET)
    public List<User> findAll(){
        List<User> users = userService.findAll();
        return users;
    }

    @RequestMapping(value="/{userId}",method = RequestMethod.GET)
    public Result findById(@PathVariable String userId){
        User user = userService.findById(userId);
        return new Result(true, StatusCode.OK,"查询成功",user);
    }
}
